package sudoku_properties;

import java.util.ArrayList;

/*****************************************************
 * Class SudokuGameInfoParam                        **
 * 1. Store the parameter of the Sudoku Settings    **
 *****************************************************/
public class SudokuGameInfoParam {

    public SudokuGameInfoParam(){}

    /* Difficulty */
    public static String[] getDifficultyLevels(){
        return DIFFICULTY_LEVELS;
    }
    public static String[] getDifficultyLevelsInChin(){
        return DIFFICULTY_LEVELS_IN_CHIN;
    }

    public static int getDifficultyLevelIndex(String inputDifficultyLevel){
        final String difficultLevel = inputDifficultyLevel;
        int difficultyIndex = 0;
        for( int i=0; i<DIFFICULTY_LEVELS.length; i++){
            if(DIFFICULTY_LEVELS[i].equalsIgnoreCase(difficultLevel)){
                difficultyIndex = i;
                break;
            }
        }
        return difficultyIndex;
    }
        public static int getDifficultyLevelIndexInChin(String inputDifficultyLevel){
        final String difficultLevel = inputDifficultyLevel;
        int difficultyIndex = 0;
        for( int i=0; i<DIFFICULTY_LEVELS_IN_CHIN.length; i++){
            if(DIFFICULTY_LEVELS_IN_CHIN[i].equalsIgnoreCase(difficultLevel)){
                difficultyIndex = i;
                break;
            }
        }
        return difficultyIndex;
    }

    public static Integer[]getDifficultyRange(int inputIndex){
        // to be improve ...
        DIFFICULTY_RANGE.clear();
        DIFFICULTY_RANGE.add(GENTLE_RANGE);
        DIFFICULTY_RANGE.add(MODERATE_RANGE);
        DIFFICULTY_RANGE.add(DIFFICULT_RANGE);
        return DIFFICULTY_RANGE.get(inputIndex);
    }
    public static int getMinDifficultyIndex(){
        return MIN_DIFFICULTY_INDEX;
    }
    public static int getMaxDifficultyIndex(){
        return MAX_DIFFICULTY_INDEX;
    }

    /* Logical rules */
    public static String[] getLogicalRules(){
        return LOGICAL_RULES;
    }
    public static String[] getLogicalRulesInChin(){
        return LOGICAL_RULES_IN_CHIN;
    }

    public static int getLogicalRulesIndex(String inputLogicalRules){
        final String logicalRules = inputLogicalRules;
        int rulesIndex = 0;
        for( int i=0; i<LOGICAL_RULES.length; i++){
            if(LOGICAL_RULES[i].equalsIgnoreCase(logicalRules)){
                rulesIndex = i;
                break;
            }
        }
        return rulesIndex;
    }
    public static int getLogicalRulesIndexInChin(String inputLogicalRules){
        final String logicalRules = inputLogicalRules;
        int rulesIndex = 0;
        for( int i=0; i<LOGICAL_RULES_IN_CHIN.length; i++){
            if(LOGICAL_RULES_IN_CHIN[i].equalsIgnoreCase(logicalRules)){
                rulesIndex = i;
                break;
            }
        }
        return rulesIndex;
    }

    // 20091017 phrase2 start
    /*return true if rankRule < compareRule */
    public static boolean isHigherRank(ArrayList<Integer> rulesRanking, String rankRule, String compareRule){
        for(int i=0; i<rulesRanking.size(); i++){
            if(LOGICAL_RULES[rulesRanking.get(i)].equalsIgnoreCase(compareRule)){
                return true;
            }
            else if(LOGICAL_RULES[rulesRanking.get(i)].equalsIgnoreCase(rankRule)){
                return false;
            }
        }
        return false;
    }
    // 20091017 phrase2 end

    public static String[] getHintsLevel(){
        return HINTS_LEVEL;
    }
    public static String[] getHintsLevelInChin(){
        return HINTS_LEVEL_IN_CHIN;
    }

    public static String getHintsSeparator(){
        return HINTS_SEPARATOR;
    }
    
    /* Game status */
    public static String getGameStatusCorrrect(){
        return GAME_STATUS_CORRECT;
    }
    public static String getGameStatusWrong(){
        return GAME_STATUS_WRONG;
    }
    /* Game status */
    public static String getGameStatusCorrrectInChin(){
        return GAME_STATUS_CORRECT_IN_CHIN;
    }
    public static String getGameStatusWrongInChin(){
        return GAME_STATUS_WRONG_IN_CHIN;
    }

    public static String[] getColumnIndexAlpha(){
        return COLUMN_INDEX_ALPHA;
    }

    // 20100112
    /* Language Mode */
    public static int getEnglishMode(){
        return ENG_MODE;
    }
    public static int getChineseMode(){
        return CHIN_MODE;
    }

    /* Local Variables*/
    /* Difficulty level representation in String*/
    private final static String[] DIFFICULTY_LEVELS = {"Gentle", "Moderate", "Difficult"};
    private final static String[] DIFFICULTY_LEVELS_IN_CHIN = {"容易", "中等", "困難"};

    /* Difficulty level vs Number of given cells */
    /* number of given cells */
    private final static Integer[] DIFFICULT_RANGE = {0, 24};
    private final static Integer[] MODERATE_RANGE = {25, 29};
    private final static Integer[] GENTLE_RANGE = {30, 81};
    private final static ArrayList<Integer[]> DIFFICULTY_RANGE = new ArrayList<Integer[]>();
    private final static int MIN_DIFFICULTY_INDEX = 0;
    private final static int MAX_DIFFICULTY_INDEX = 1;

    /* Logical Rules of Sudoku in String */
    private final static String[] LOGICAL_RULES  = {"Single In Group",
    "Naked Single ", "Hidden Single", "Intersection Reduction", "Naked Pairs", "Hiddden Pairs"};
    private final static String[] LOGICAL_RULES_IN_CHIN  = {"唯一候選數法",
    "顯式唯一法", "隱式唯一法", "區塊刪減法", "顯式數對刪減法", "隱性數對刪減法"};

    /* Level of Hints */
    private final static String[] HINTS_LEVEL 
            = {"Row Hint", "Colum Hint", "Rules Hint", "Answer Hint"};
     private final static String[] HINTS_LEVEL_IN_CHIN
            = {"行數提示", "列數提示", "規則提示", "直接答案"};

    // 20091017 phrase2 start
    private final static String HINTS_SEPARATOR = "|";
    // 20091017 phrase2 end
    private final static String GAME_STATUS_CORRECT = "You are doing quite well so far.";
    private final static String GAME_STATUS_WRONG = "Something(s) goes wrong.";
        private final static String GAME_STATUS_CORRECT_IN_CHIN = "暫時做得不錯。";
    private final static String GAME_STATUS_WRONG_IN_CHIN = "有一(多)個出錯。";

    private final static String[] COLUMN_INDEX_ALPHA = {"","A","B","C","D","E","F","G","H","I"};

    // 20100112
    /* Language Mode */
    private final static int CHIN_MODE = 0;
    private final static int ENG_MODE = 1;



}
